﻿using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Coldairarrow.Entity.apifox
{

    //public partial class ApifoxModel
    //{
    //    [JsonProperty("data")]
    //    public Data Data { get; set; }

    //    [JsonProperty("success")]
    //    public bool Success { get; set; }
    //}
    public partial class ApifoxModel
    {
        [JsonProperty("apiCollection")]
        public ApiCollection ApiCollection { get; set; }

        [JsonProperty("docCollection")]
        public DocCollection DocCollection { get; set; }

        [JsonProperty("environment")]
        public Environment Environment { get; set; }

        [JsonProperty("responseCollection")]
        public ResponseCollection ResponseCollection { get; set; }

        [JsonProperty("schemaCollection")]
        public SchemaCollection SchemaCollection { get; set; }

        [JsonProperty("socketCollection")]
        public SocketCollection SocketCollection { get; set; }

        [JsonProperty("testCaseCollection")]
        public TestCaseCollection TestCaseCollection { get; set; }

        [JsonProperty("testSuiteCollection")]
        public TestSuiteCollection TestSuiteCollection { get; set; }
    }

    public partial class ApiCollection
    {
        [JsonProperty("folder")]
        public ApiCollectionFolder Folder { get; set; }

        [JsonProperty("item")]
        public ApiCollectionItem Item { get; set; }
    }

    public partial class ApiCollectionFolder
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class ApiCollectionItem
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class DocCollection
    {
        [JsonProperty("folder")]
        public DocCollectionFolder Folder { get; set; }

        [JsonProperty("item")]
        public DocCollectionItem Item { get; set; }
    }

    public partial class DocCollectionFolder
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class DocCollectionItem
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class Environment
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class ResponseCollection
    {
        [JsonProperty("defaultEnable")]
        public bool DefaultEnable { get; set; }

        [JsonProperty("name")]
        public string Name { get; set; }

        [JsonProperty("code")]
        public int Code { get; set; }

        [JsonProperty("contentType")]
        public string ContentType { get; set; }

        [JsonProperty("id")]
        public string Id { get; set; }

        [JsonProperty("jsonSchema")]
        public object jsonSchema { get; set; }
    }

    public partial class SchemaCollection
    {
        [JsonProperty("folder")]
        public SchemaCollectionFolder Folder { get; set; }

        [JsonProperty("item")]
        public SchemaCollectionItem Item { get; set; }
    }

    public partial class SchemaCollectionFolder
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class SchemaCollectionItem
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class SocketCollection
    {
        [JsonProperty("api")]
        public Api Api { get; set; }

        [JsonProperty("folder")]
        public SocketCollectionFolder Folder { get; set; }

        [JsonProperty("service")]
        public Service Service { get; set; }
    }

    public partial class Api
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class SocketCollectionFolder
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class Service
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class TestCaseCollection
    {
        [JsonProperty("folder")]
        public TestCaseCollectionFolder Folder { get; set; }

        [JsonProperty("item")]
        public TestCaseCollectionItem Item { get; set; }
    }

    public partial class TestCaseCollectionFolder
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class TestCaseCollectionItem
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class TestSuiteCollection
    {
        [JsonProperty("folder")]
        public TestSuiteCollectionFolder Folder { get; set; }

        [JsonProperty("item")]
        public TestSuiteCollectionItem Item { get; set; }
    }

    public partial class TestSuiteCollectionFolder
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    public partial class TestSuiteCollectionItem
    {
        [JsonProperty("createCount")]
        public long CreateCount { get; set; }

        [JsonProperty("errorCount")]
        public long ErrorCount { get; set; }

        [JsonProperty("ignoreCount")]
        public long IgnoreCount { get; set; }

        [JsonProperty("updateCount")]
        public long UpdateCount { get; set; }
    }

    //public partial class ApifoxModel
    //{
    //    public static ApifoxModel FromJson(string json) => JsonConvert.DeserializeObject<ApifoxModel>(json, apifox.Converter.Settings);
    //}

    public static class Serialize
    {
        public static string ToJson(this ApifoxModel self) => JsonConvert.SerializeObject(self, apifox.Converter.Settings);
    }

    internal static class Converter
    {
        public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
        {
            MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
            DateParseHandling = DateParseHandling.None,
            Converters =
            {
                new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
            },
        };
    }
}

